package com.coolgor.axnut.web.seal;

import org.springframework.stereotype.Controller;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.coolgor.axnut.util.HttpServletRequestUtil;
import com.coolgor.axnut.dto.mdmis.PolicyMonitorExecution;
import com.coolgor.axnut.dto.seal.SealCategoryExecution;
import com.coolgor.axnut.entity.mdmis.PolicyCondition;
import com.coolgor.axnut.entity.mdmis.PolicyMonitor;
import com.coolgor.axnut.entity.seal.SealCategory;
import com.coolgor.axnut.enums.seal.SealCategoryOperationStateEnum;
import com.coolgor.axnut.service.mdmis.PolicyMonitorService;
import com.coolgor.axnut.service.seal.SealCategoryService;


@Controller
@RequestMapping(value="seal", method={RequestMethod.GET,RequestMethod.POST})
public class SealCategoryController {
	@Autowired
	private  SealCategoryService sealCategoryService;
	
	@RequestMapping(value = "/getSealCategory", method={RequestMethod.POST})
	@ResponseBody
	private Map<String, Object> getSealCategory(@RequestBody SealCategory sealCategoryCondition, HttpServletRequest request) {
		System.out.println("`````````````````````````");
		Map<String, Object> modelMap = new HashMap<String, Object>();
		SealCategoryExecution exe = sealCategoryService.getSealCategoryList(sealCategoryCondition, 0, 99);
		if (null != exe && exe.getState()==SealCategoryOperationStateEnum.SUCCESS.getState()) {
			try {
				modelMap.put("total",exe.getCount());
				modelMap.put("data",exe.getList());
				modelMap.put("success", true);
			} catch (Exception e) {
				modelMap.put("success", false);
				modelMap.put("errMsg", e.toString());
			}
		} else {
			modelMap.put("success", false);
			modelMap.put("errMsg", "Operation Error");
		}
		return modelMap;
	}	
	
	
}
